﻿#include "Game.h"


Game::Game(void)
{
	state = GAME_MENU;
	player = new Player();

	mainMenu = new menu(&state, STYLE_VERTICAL | STYLE_ORNAMENTS);
	mainMenu->add("New Game", GAME_START);
	mainMenu->add("Continue", GAME_LOAD);
	mainMenu->add("Options", GAME_OPTIONS);
	mainMenu->add("Run away...", GAME_EXIT);
}

Game::~Game(void)
{
}

void Game::showUpperBar()
{
	writeLineOf('#');
	writeChars('#', 4);
	cout << " ";
	cout << player->getName().c_str();
	cout << " ";
	space(20-player->getName().length());
	// 26 of 80 used
	writeChars('#', 19);
	// 32 of 80
	cout << " HP: ";
	string health = intToStr(player->getHealth());
	cout << health.c_str();
	cout << " / ";
	string healthMax = intToStr(player->getHealth());
	cout << healthMax.c_str() << " ";

	space(22 - 3 - health.size() - 3 - healthMax.size());

	// 62 of 80 used
	writeChars('#', 10);
	writeLineOf('#');
}

void Game::showLogo()
{
	// Game Logo - ~1 hour of work
	setTextColor(COLOR_YELLOW);
	wchar_t* image[] = {
		{L"      ██                ██       ███████████████████████████████████████████████"},
		{L"    ████                ████     ██                                           ██"},
		{L"   ███████            ███████    ██  █████ ██ ██ ████ ██   ████ █████ ██████  ██"},
		{L"  ████████            ████████   ██  ██ ██ ██ ██ ██   ██   ██   ██ ██ ██  ██  ██"},
		{L" ███████████        ███████████  ██  ██ ██ ██ ██ ██   ██   ████ █████ ██████  ██"},
		{L"█████████████      █████████████ ██  ██ ██ ██ ██ ██   ██   ██   ██ ██ ██ ██   ██"},
		{L"              ████               ██  ██ ██ █████ ████ ████ ████ ██ ██ ██  ██  ██"},
		{L"             ██████              ██                                           ██"},
		{L"              ████               ██  Nuclear Cry          ████ ██████ ██  ██  ██"},
		{L"                                 ██    By. Crypton        ██   ██  ██ ██  ██  ██"},
		{L"              ████               ██                       ██   ██████  ████   ██"},
		{L"             ██████              ██      Have fun         ██   ██ ██    ██    ██"},
		{L"            ████████             ██       And stay alive  ████ ██  ██   ██    ██"},
		{L"           ██████████            ██                                           ██"},
		{L"          ████████████           ███████████████████████████████████████████████"}
	};

	for (int i = 0; i < 15; i++)
		cout << image[i] << flush;

	setTextColor(COLOR_YELLOW);
	writeLine(LINE_NORMAL);
	setTextColor(COLOR_WHITE);
}

void Game::doTheMagic()
{
	while(true)
	{
		switch(state)
		{
		case GAME_START:
		{
			showUpperBar();
			cin.get();
			break;
		}
		case GAME_MENU:
			{
				showLogo();
				mainMenu->show();
				mainMenu->think();
				cin.get();
				break;
			}
		default:
			break;
		}

		system("cls");
	}
}